var Geometry = (function () {

  function Circle(x, y, r)
  {
    this.x = x;
    this.y = y;
    this.r = r;
  }
  
  Circle.MP = 0.5;

  Circle.prototype.midpoint =
    function (c)
    {
      return new Point((this.x+c.x) * Circle.MP, (this.y+c.y) * Circle.MP);    
    }
      
  function intersect(c1, c2)
  {
    var d = Math.sqrt((c2.y-c1.y)*(c2.y-c1.y) + (c2.x-c1.x)*(c2.x-c1.x));
    return (c1.r + c2.r) >= d; 
  }
  
  function Point(x, y)
  {
    // CHANGE TO
    // Circle.call(this, x, y, 0);
    this.x = x;
    this.y = y;
    this.r = 0;
  }
  Point.prototype = Object.create(Circle.prototype);
  
  Point.prototype.toString =
    function ()
    {
      return "{x:" + this.x + ", y:" + this.y + "}";
    }
  
  return {Circle:Circle, Point:Point, intersect:intersect};
})();

///

var c = {x:10, y:20, r:50};
var p = new Geometry.Point(90, 90);
p.midpoint(c);

